const express = require('express');
const router = express.Router();
const userController = require('../controllers/user');
const { verifyToken } = require('../middlewares/auth');
const upload = require('../middlewares/upload');

router.post('/register', userController.register);
router.post('/login', userController.login);
router.get('/info', verifyToken, userController.getInfo);
router.put('/info', verifyToken, userController.updateInfo);

// 将原来的upload配置替换为新的中间件
router.post('/avatar', verifyToken, upload.single('avatar'), userController.updateAvatar);

// 新增/保持：统一资料更新接口（现支持 avatar 字符串）
router.put('/credentials', verifyToken, userController.updateCredentials);

module.exports = router;